<template>
    <div class="edit">
        <el-dialog style="width: 560px;" title="设置排序" v-model="props.visible" :key='tablekey' :before-close="beforeClose">
            <el-form :model="formVlue" label-width="100px">
                <el-form-item label="排序">
                    <el-input v-model="formVlue.name" style="width: 250px;"></el-input>
                </el-form-item>
                <el-form-item label="每日开始时间">
                    <el-col :span="11">
                        <el-time-picker v-model="formVlue.createTime" placeholder="Pick a time" style="width: 100%" />
                    </el-col>
                </el-form-item>
                <el-form-item label="每日结束时间">
                    <el-col :span="11">
                        <el-time-picker v-model="formVlue.endTime" placeholder="Pick a time" style="width: 100%" />
                    </el-col>
                </el-form-item>
                <el-form-item label="是否启用">
                    <el-radio-group v-model="formVlue.status" class="ml-4">
                        <el-radio :label="1" size="large">是</el-radio>
                        <el-radio :label="2" size="large">否</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="onCancel">取消</el-button>
                    <el-button type="primary" @click="onConfirm">
                        确定
                    </el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup lang="ts">
import { ref, defineProps, withDefaults, defineEmits, watch } from 'vue';
import { msAllRES } from '../../../json/request/QmsAdminConreiller/index'
import type { Ref } from 'vue'
let tablekey = ref(0)
let props = withDefaults(
    defineProps<{
        visible: boolean;
        form: msAllRES
    }>(), {
    visible: true
}
)
let formVlue = ref({}) as Ref<msAllRES>
watch(
    () => props.form,
    (newVal) => {
        console.log(newVal);
        formVlue.value = { ...newVal };
        console.log(formVlue.value);
        tablekey.value++
        // console.log(tablekey.value);

        // f.value = { ...newVal };
    }
);
// console.log(formVlue.value);

// 取消
let emits = defineEmits<
    {
        (event: 'cancel'): void;
        (event: 'sure'): void;
    }
>()
let onCancel = () => {
    emits('cancel')
}
let beforeClose = () => {
    emits('cancel')
}
// 确定
let onConfirm = () => {
    emits('sure')
}

</script>

<style scoped lang="scss"></style>